/******************************************************************************************
 * Import
 ******************************************************************************************/

// module
import Taro, { Component } from '@tarojs/taro'
import { Swiper } from '@tarojs/components'
import { AtActionSheet, AtActionSheetItem } from "taro-ui"

// project
import { CPage, CContent, CHeader, CFooter, CFloat, CAround, CBetween, CCenter, CRow, CWrap, CLine, CHand, CItemX, CItemY, CLabel, CSvg, CImage, CButton, CColumn } from '../../../library/comp';
import { Base64, Gen, Time, Zip, Session, Storage, Toast} from '../../../library/func';
import Icon from '../../../project/style/icon';
import Http from '../../../project/func/http/http'
import Util from '../../../project/func/util';

// 引用组件
// import { Logoline, Listunitone, Mfooter, Listunittwo} from '../../preset'

/******************************************************************************************
 * Export Class
 ******************************************************************************************/

export default class Listunitone extends Component {

	constructor(props) {
		super(props);

		/**
		 * state
		 */
		this.state = {

		}
    }
    
    /*------------------------------------------------------------------------------------
	 * 自定义方法
	 *-----------------------------------------------------------------------------------*/
    // 气泡显隐
    show = ()=> {
        this.setState({
            show: !this.state.show
        })
    }
    // 点击取消按钮
    onCancel = ()=> {
        this.setState({
            show: false
        })
    }
    // 点击遮罩层
    onClose = ()=> {
        this.setState({
            show: false
        })
    }
    
    // 点击置顶
    top = ()=> {
        this.props.onTob();
        this.setState({
            show:false
        })
        console.log('置顶')
    }

    // onRedirect
    onRedirect(url){
        wx.redirectTo({
            url: url
        })
    }
    // onNavigate
    onNavigate(url){
        wx.navigateTo({
            url: url
        })
    }
    //onNavigateBack
    onNavigateBack(num=1){
        wx.navigateBack({
            delta: num
        })                    
    }

	/**
	 * 渲染
	 */
	render() {
    
		// 渲染
		return (
            <CColumn bg='#fff' px='10' mb='10' onClick={this.onNavigate.bind(this, this.props.url)}>
                <CBetween pt='10'>
                    { this.props.data.is_top ? 
                        <CHand y='center'><CSvg icon={Icon.maketop} color="#d66352" w='18' h='18'></CSvg><CHand size='13' color='#d66352' ml='8'>置顶</CHand></CHand>
                        :
                        <CHand y='center'></CHand>
                    }
                    <CHand>
                        {
                            this.props.is_master ?
                            <CSvg color="#999" icon={Icon.down} w='18' h='18' onClick={this.show}></CSvg>
                            :
                            <CHand></CHand>
                        }
                        {/* 气泡 */}
                        <AtActionSheet isOpened={this.state.show} cancelText='取消' onCancel={this.onCancel} onClose={this.onClose}>
                            <AtActionSheetItem onClick={this.top}>置顶</AtActionSheetItem>
                        </AtActionSheet>
                    </CHand>
                </CBetween>
                <CItemX py='10' bb="#eee 5" style='width:100%'>
                    <CBetween>
                        <CHand class='f03' h="120" style='width:30%'>
                            <CImage 
                                w="100"
                                h="120"
                                src={ this.props.data.object.set_cover }
                            />
                        </CHand>
                        <CHand y="top" px='10' h="120" style='width:70%'>
                            <CItemY x='left' style='width:100%'>
                                <CLine>
                                    <CHand size="16" color='#2e2e2e'>{ this.props.data.set_title }</CHand>
                                </CLine>
                                <CItemX style='width:100%' mt='10'>
                                    <CLine>
                                        <CHand size="14" color='#3c3c3c'>{ this.props.data.count_apply }人参与</CHand>
                                        <CHand color="#666" ml="10" size="12" color='#707070'>仅限{ this.props.data.set_limit }人</CHand>
                                    </CLine>
                                    <CHand color='#313131' size='14' pr='20'>{ this.props.data.set_address }</CHand>
                                </CItemX>
                                <CLine>
                                    <CHand color="#707070" mt='10' size="14">{ Util.formatTime(this.props.data.time_start,'Y年M月D日 h:m')  }</CHand>
                                </CLine>
                                <CLine>
                                    <CHand color="#707070" mt='10' size="14">{ this.props.data.enum_type }</CHand>
                                </CLine>
                            </CItemY>
                        </CHand>
                        {/* <CHand f="0.3" h="120" y="top">
                            <CItemY f="1" x="center">
                                <CHand>
                                    <CHand lh="30" size="12">保定</CHand>
                                </CHand>
                            </CItemY>
                        </CHand> */}
                    </CBetween>
                </CItemX>
            </CColumn>
		);
	}
};